import {
  get,
  post,
} from "./base_service"


/**
 * 首页相关请求接口
 *
 * allen  2021-08-02
 */

/**
 * 首页顶部数字
 */
const houseQueryTagRequest = (cityName) => {
  return new Promise((resolve, reject) => {
    get("/new/house/query/main/tag/number?cityName=" + cityName).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
 * 查询首页新闻
 */
const queryHomeNews = () => {
  return new Promise((resolve, reject) => {
    get("/news/query/home").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

/**
 * 查询首页要展示的房源
 */
const queryHomeShowHouseList = (cityName) => {
  return new Promise((resolve, reject) => {
    post("/new/house/home/view/list?cityName=" + cityName).then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}
/**
 * 获取详情提示
 */

const getHouseDetailTips = () => {
  return new Promise((resolve, reject) => {
    get("/setting/detail/tips").then((data) => {
      if (data.code == 200) {
        resolve(data)
      } else {
        reject(data.msg)
      }
    }).catch((e) => {
      reject(e.message)
    })
  })
}

module.exports = {
  houseQueryTagRequest,
  queryHomeNews,
  queryHomeShowHouseList,
  getHouseDetailTips
}

